<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
unset( $top[0]['type'] );
unset( $top[0]['type_id'] );
unset( $top[0]['depth'] );
unset( $top[0]['title'] );
unset( $top[0]['url'] );
unset( $top[0]['id'] );
$count = 0;
$keys = array_keys( $top[0] );
?>
<ul class="sf-menu left-menu">
	<?php while( $count <= 4 ){ 
		$liclass = '';
		if( $top[0][$keys[$count]]['url'] == $menu_url ){
			$liclass = 'class="active"';
		} else {
			foreach( $top[0][$keys[$count]] as $key => $value ){
				if( is_array( $value ) ){
					if( $value['url'] == $menu_url ){
						$liclass = 'class="active"';
					}
				}
			}
		} 
		?>
		<li id="item<?php echo $count + 1; ?>" <?php echo $liclass; ?>><a href="<?php echo site_url( ); ?>/welcome/page/<?php echo $top[0][$keys[$count]]['url']; ?>"><?php echo $top[0][$keys[$count]]['title']?></a>
	    	<?php
			unset( $top[0][$keys[$count]]['type'] );
			unset( $top[0][$keys[$count]]['type_id'] );
			unset( $top[0][$keys[$count]]['depth'] );
			unset( $top[0][$keys[$count]]['title'] ); 
			unset( $top[0][$keys[$count]]['url'] ); 
			unset( $top[0][$keys[$count]]['id'] ); 
			//@todo: check if it could be solved better!
			$title = 0;
			foreach( $top[0][$keys[$count]] as $key => $value ){
				$title += ( !empty( $value['title'] ) ) ? 1 : 0;
			}
			if( !empty( $top[0][$keys[$count]] ) && $title != 0 ){
			?>
	    	<ul>
	        	<?php
	        	$i = 1;
	        	$nums = count( $top[0][$keys[$count]] );
				foreach( $top[0][$keys[$count]] as $key => $value ){ 
					$class = '';
					if( $i == 1 )	
						$class .= 'first ';
					if( $i == $nums )
						$class .= 'last';
					if( !empty( $value['title'] ) ){
						?>
			            <li id="item<?php echo $count + 1; ?>-<?php echo $i; ?>" class="<?php echo $class; ?>"><a href="<?php echo site_url( ); ?>/welcome/page/<?php echo $value['url']?>"><?php echo $value['title']; ?></a></li>
	        			<?php 
					} //if
	        		$i++;
				} //foreach ?>
			</ul>
			<?php } //if ?>
		</li>
		<?php 
		$count++;
	} //while ?>
</ul>
<ul class="sf-menu right-menu">
	<?php while( $count <= 9 ){ ?>
		<li id="item<?php echo $count + 1; ?>"><a href="<?php echo site_url( ); ?>/welcome/page/<?php echo $top[0][$keys[$count]]['url']; ?>"><?php echo $top[0][$keys[$count]]['title']?></a>
	    	<?php
			unset( $top[0][$keys[$count]]['type'] );
			unset( $top[0][$keys[$count]]['type_id'] );
			unset( $top[0][$keys[$count]]['depth'] );
			unset( $top[0][$keys[$count]]['title'] ); 
			unset( $top[0][$keys[$count]]['url'] ); 
			unset( $top[0][$keys[$count]]['id'] ); 
			if( !empty( $top[0][$keys[$count]] ) ){
			?>
	    	<ul>
				<?php
	        	$i = 1;
	        	$nums = count( $top[0][$keys[$count]] );
				foreach( $top[0][$keys[$count]] as $key => $value ){ 
					$class = '';
					if( $i == 1 )	
						$class .= 'first ';
					if( $i == $nums )
						$class .= 'last'
					?>
	            	<li id="item<?php echo $count + 1; ?>-<?php echo $i; ?>" class="<?php echo $class; ?>"><a href="<?php echo site_url( ); ?>/welcome/page/<?php echo $value['url']?>"><?php echo $value['title']; ?></a></li>
	            	<?php 
	            	$i++;
				} //foreach ?>
			</ul>
			<?php } //if ?>
		</li>
		<?php 
		$count++;
	} //while ?>
</ul>
